<div class="form">

<?php 
Yii::app()->clientScript->registerCoreScript('jquery');
$form=$this->beginWidget('CActiveForm', array(
	'id'=>'adminhtml-node-form',
	//'enableAjaxValidation'=>true,
)); /* @var $form CActiveForm */?>

	<p class="note">标识 <span class="required">*</span> 为必填项.</p>

	<?php echo Yii::app()->admin->showPutMsg(); ?>
	<?php echo $form->errorSummary($model); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'node_name'); ?>
		<?php echo $form->textField($model,'node_name',array('size'=>30,'maxlength'=>45)); ?>
		<?php echo $form->error($model,'node_name'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'p_id'); ?>
		<?php echo $form->dropDownList($model,'p_id', AdminhtmlHelper::getNodeOptions()  ); ?>
		<?php echo $form->error($model,'p_id'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'node_code'); ?>
		<?php echo $form->textField($model,'node_code',array('size'=>30,'maxlength'=>100)); ?>
		<?php echo $form->error($model,'node_code'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'controller'); ?>
		<?php $exceptionControllers= $model->getRemainControllers($model->controller); 
		$array = AdminhtmlHelper::getControllerOptions(true, $exceptionControllers);
		?>
		<?php echo $form->dropDownList($model,'controller', array_merge(array(''=>'- 未定义 -'), $array ) ); ?>
		<?php echo $form->error($model,'controller'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'node_url'); ?>
		<?php echo $form->textField($model,'node_url',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'node_url'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'sort'); ?>
		<?php echo $form->textField($model,'sort',array('size'=>10,'maxlength'=>10)); ?>
		<?php echo $form->error($model,'sort'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'status'); ?>
		<?php echo $form->dropDownList($model,'status', AdminhtmlHelper::getStatusOptions()  ); ?>
		<?php echo $form->error($model,'status'); ?>
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>

<?php $this->endWidget(); ?>
<script type="text/javascript">
$('#AdminhtmlNode_controller').change(function(){
	var name= $('#AdminhtmlNode_controller').val();
	name= name.substring(0,name.length -10);
	$('#AdminhtmlNode_node_code').val(name);
	$('#AdminhtmlNode_node_url').val('adminhtml/'+ name+ '/admin');
	if(!$('#AdminhtmlNode_node_name').val())
		$('#AdminhtmlNode_node_name').val(name);
});
//camelize date exchange
function camelize(str){
	return str.replace(/_(w)/g, function(all, letter){
        return letter.toUpperCase();
    });
}
function unCamelize(str){
	var result= str.replace(/([A-Z])/g,"_$1").toLowerCase();
	return result.substring(1);
}
</script>
</div><!-- form -->